<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Nabu-asr: ops.py File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Nabu-asr
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_5a19dd24bd3679bb79d0ed8fbf6eb6c5.html">nabu</a></li><li class="navelem"><a class="el" href="dir_58864515de009ec37b00c7c6d6449040.html">neuralnetworks</a></li><li class="navelem"><a class="el" href="dir_cbbf0d63f81975b97cb7de71ded32bc5.html">components</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">ops.py File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>some operations  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:aa0526046773823364ea28b5ec2034677"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ops_8py.html#aa0526046773823364ea28b5ec2034677">nabu.neuralnetworks.components.ops.pyramid_stack</a> (inputs, sequence_lengths, numsteps, axis=2, scope=None)</td></tr>
<tr class="memdesc:aa0526046773823364ea28b5ec2034677"><td class="mdescLeft">&#160;</td><td class="mdescRight">concatenate each two consecutive elements  <a href="ops_8py.html#aa0526046773823364ea28b5ec2034677">More...</a><br /></td></tr>
<tr class="separator:aa0526046773823364ea28b5ec2034677"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3a812ed0784ea3e9094de59b1240c720"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ops_8py.html#a3a812ed0784ea3e9094de59b1240c720">nabu.neuralnetworks.components.ops.stack_seq</a> (sequential, sequence_lengths, name=None)</td></tr>
<tr class="memdesc:a3a812ed0784ea3e9094de59b1240c720"><td class="mdescLeft">&#160;</td><td class="mdescRight">remove padding and stack sequences  <a href="ops_8py.html#a3a812ed0784ea3e9094de59b1240c720">More...</a><br /></td></tr>
<tr class="separator:a3a812ed0784ea3e9094de59b1240c720"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adbea8ae1db9af1c8501d7720d2c90ad3"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ops_8py.html#adbea8ae1db9af1c8501d7720d2c90ad3">nabu.neuralnetworks.components.ops.unstack_seq</a> (nonseq, sequence_lengths, name=None)</td></tr>
<tr class="memdesc:adbea8ae1db9af1c8501d7720d2c90ad3"><td class="mdescLeft">&#160;</td><td class="mdescRight">unstack sequences and add padding  <a href="ops_8py.html#adbea8ae1db9af1c8501d7720d2c90ad3">More...</a><br /></td></tr>
<tr class="separator:adbea8ae1db9af1c8501d7720d2c90ad3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2f3941f9c4455335eb5ae4ebcea4f4b8"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ops_8py.html#a2f3941f9c4455335eb5ae4ebcea4f4b8">nabu.neuralnetworks.components.ops.dense_sequence_to_sparse</a> (sequences, sequence_lengths)</td></tr>
<tr class="memdesc:a2f3941f9c4455335eb5ae4ebcea4f4b8"><td class="mdescLeft">&#160;</td><td class="mdescRight">convert sequence dense representations to sparse representations  <a href="ops_8py.html#a2f3941f9c4455335eb5ae4ebcea4f4b8">More...</a><br /></td></tr>
<tr class="separator:a2f3941f9c4455335eb5ae4ebcea4f4b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a259e1c1f8aa0f0fb28d06e562cf4c07e"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ops_8py.html#a259e1c1f8aa0f0fb28d06e562cf4c07e">nabu.neuralnetworks.components.ops.get_indices</a> (sequence_length)</td></tr>
<tr class="memdesc:a259e1c1f8aa0f0fb28d06e562cf4c07e"><td class="mdescLeft">&#160;</td><td class="mdescRight">get the indices corresponding to sequences (and not padding)  <a href="ops_8py.html#a259e1c1f8aa0f0fb28d06e562cf4c07e">More...</a><br /></td></tr>
<tr class="separator:a259e1c1f8aa0f0fb28d06e562cf4c07e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8bf6b06b5c1d6e69ad73f2101f2b478a"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ops_8py.html#a8bf6b06b5c1d6e69ad73f2101f2b478a">nabu.neuralnetworks.components.ops.pad_to</a> (tensor, length, axis=0, name=None)</td></tr>
<tr class="memdesc:a8bf6b06b5c1d6e69ad73f2101f2b478a"><td class="mdescLeft">&#160;</td><td class="mdescRight">pad the tensor to a certain length  <a href="ops_8py.html#a8bf6b06b5c1d6e69ad73f2101f2b478a">More...</a><br /></td></tr>
<tr class="separator:a8bf6b06b5c1d6e69ad73f2101f2b478a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a71d8d0f12f6d57670eecfa88b2f8b41e"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ops_8py.html#a71d8d0f12f6d57670eecfa88b2f8b41e">nabu.neuralnetworks.components.ops.map_ta</a> (fn, ta)</td></tr>
<tr class="memdesc:a71d8d0f12f6d57670eecfa88b2f8b41e"><td class="mdescLeft">&#160;</td><td class="mdescRight">apply fn to each element in tensorarray  <a href="ops_8py.html#a71d8d0f12f6d57670eecfa88b2f8b41e">More...</a><br /></td></tr>
<tr class="separator:a71d8d0f12f6d57670eecfa88b2f8b41e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>some operations </p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="file_a2f3941f9c4455335eb5ae4ebcea4f4b8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a2f3941f9c4455335eb5ae4ebcea4f4b8">&sect;&nbsp;</a></span>dense_sequence_to_sparse()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.neuralnetworks.components.ops.dense_sequence_to_sparse </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>sequences</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>sequence_lengths</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>convert sequence dense representations to sparse representations </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sequences</td><td>the dense sequences as a [batch_size x max_length] tensor </td></tr>
    <tr><td class="paramname">sequence_lengths</td><td>the sequence lengths as a [batch_size] vector</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the sparse tensor representation of the sequences </dd></dl>

</div>
</div>
<a id="file_a259e1c1f8aa0f0fb28d06e562cf4c07e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a259e1c1f8aa0f0fb28d06e562cf4c07e">&sect;&nbsp;</a></span>get_indices()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.neuralnetworks.components.ops.get_indices </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>sequence_length</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>get the indices corresponding to sequences (and not padding) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sequence_length</td><td>the sequence_lengths as a N-D tensor</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A [sum(sequence_length) x N-1] Tensor containing the indices </dd></dl>

</div>
</div>
<a id="file_a71d8d0f12f6d57670eecfa88b2f8b41e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a71d8d0f12f6d57670eecfa88b2f8b41e">&sect;&nbsp;</a></span>map_ta()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.neuralnetworks.components.ops.map_ta </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>fn</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>ta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>apply fn to each element in tensorarray </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">fn</td><td>the function to apply </td></tr>
    <tr><td class="paramname">ta</td><td>the tensorarray</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the resulting tensorarray </dd></dl>

</div>
</div>
<a id="file_a8bf6b06b5c1d6e69ad73f2101f2b478a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a8bf6b06b5c1d6e69ad73f2101f2b478a">&sect;&nbsp;</a></span>pad_to()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.neuralnetworks.components.ops.pad_to </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>tensor</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>axis</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>name</em> = <code>None</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>pad the tensor to a certain length </p>
<ul>
<li>tensor: the tensor to pad</li>
<li>length: the length to pad to, has to be larger than tensor.shape[axis]</li>
<li>axis: the axis to pad</li>
<li>name: the name of the operation</li>
</ul>
<dl class="section return"><dt>Returns</dt><dd>the padded tensor </dd></dl>

</div>
</div>
<a id="file_aa0526046773823364ea28b5ec2034677"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_aa0526046773823364ea28b5ec2034677">&sect;&nbsp;</a></span>pyramid_stack()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.neuralnetworks.components.ops.pyramid_stack </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>inputs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>sequence_lengths</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>numsteps</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>axis</em> = <code>2</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>scope</em> = <code>None</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>concatenate each two consecutive elements </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">inputs</td><td>A time minor tensor [batch_size, time, input_size] </td></tr>
    <tr><td class="paramname">sequence_lengths</td><td>the length of the input sequences </td></tr>
    <tr><td class="paramname">numsteps</td><td>number of time steps to concatenate </td></tr>
    <tr><td class="paramname">axis</td><td>the axis where the inputs should be stacked </td></tr>
    <tr><td class="paramname">scope</td><td>the current scope</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd></dd>
<dd>
inputs Concatenated inputs <div class="fragment"><div class="line">           [batch_size, time/numsteps, input_size*numsteps]</div><div class="line">@<span class="keywordflow">return</span>        sequence_lengths    the lengths of the inputs sequences [batch_size]</div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="file_a3a812ed0784ea3e9094de59b1240c720"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a3a812ed0784ea3e9094de59b1240c720">&sect;&nbsp;</a></span>stack_seq()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.neuralnetworks.components.ops.stack_seq </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>sequential</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>sequence_lengths</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>name</em> = <code>None</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>remove padding and stack sequences </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sequential</td><td>the sequential data which is a [batch_size, max_length, dim] </td></tr>
    <tr><td class="paramname">tensor</td><td></td></tr>
    <tr><td class="paramname">sequence_lengths</td><td>a [batch_size] vector containing the sequence lengths </td></tr>
    <tr><td class="paramname">name</td><td>[optional] the name of the operation</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>non sequential data, which is a TxF tensor where T is the sum of all sequence lengths </dd></dl>

</div>
</div>
<a id="file_adbea8ae1db9af1c8501d7720d2c90ad3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_adbea8ae1db9af1c8501d7720d2c90ad3">&sect;&nbsp;</a></span>unstack_seq()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.neuralnetworks.components.ops.unstack_seq </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>nonseq</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>sequence_lengths</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>name</em> = <code>None</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>unstack sequences and add padding </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">nonseq</td><td>the non sequential data which is a [sum(sequence_lengths) x dim] tensor </td></tr>
    <tr><td class="paramname">sequence_lengths</td><td>a [batch_size] vector containing the sequence lengths </td></tr>
    <tr><td class="paramname">name</td><td>[optional] the name of the operation</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>sequential data, which is a [batch_size, max_length, dim] tensor </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.12
</small></address>
</body>
</html>
